package com.forum.module.system.convert.role;

import com.forum.framework.common.util.colletion.CollectionUtils;
import com.forum.framework.common.util.object.BeanUtils;
import com.forum.module.system.controller.admin.role.vo.RoleRespVO;
import com.forum.module.system.dal.dataobject.role.RoleDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface RoleCovert {
    RoleCovert INSTANCE = Mappers.getMapper(RoleCovert.class);

    default List<RoleRespVO> covertList(List<RoleDO> list) {
        return CollectionUtils.convertList(list, this::covert);
    }

    default RoleRespVO covert(RoleDO roleDO) {
        return BeanUtils.toBean(roleDO, RoleRespVO.class);
    }
}
